var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        showFilter: !1,
        showDatetime: !1,
        currentDate: new Date().getTime(),
        list: [],
        id: 0,
        leader_name: "",
        member_num: "",
        status: "",
        statuslist: [ {
            id: 0,
            name: "提交"
        }, {
            id: 1,
            name: "拼团中"
        }, {
            id: 2,
            name: "成功"
        }, {
            id: 3,
            name: "失败"
        } ],
        showShare: !1,
        options: [ {
            name: "分享好友",
            icon: "wechat",
            openType: "share"
        } ],
        activeID: 0,
        isLoadMore: !0,
        total_page: 0,
        page: 1,
        activeInfo: {}
    },
    onLoad: function(t) {
        t.id && this.setData({
            id: t.id
        }), this.getData();
    },
    getData: function(t) {
        var e = this, s = {
            id: this.data.id,
            store_id: this.options.store_id,
            page: this.data.page,
            leader_name: this.data.leader_name,
            member_num: this.data.member_num,
            status: this.data.status
        }, i = a.getNetAddresss("plugin.fight-groups.frontend.store.team-store.search");
        a._getNetWork({
            url: i,
            data: s,
            success: function(a) {
                var s = a.data;
                1 == s.result && (e.setData({
                    isLoadMore: !0,
                    total_page: s.data.last_page,
                    list: s.data.data
                }), t ? e.onClickRight() : e.getLevels());
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var t = this, e = a.getNetAddresss("plugin.fight-groups.frontend.store.team-store.search");
        t.data.isLoadMore = !1, this.data.page >= this.data.total_page || (this.data.page = this.data.page + 1, 
        a._postNetWork({
            url: e,
            showToastIn: !1,
            data: {
                id: t.data.id,
                store_id: this.options.store_id,
                page: t.data.page,
                leader_name: t.data.leader_name,
                member_num: t.data.member_num,
                status: t.data.status
            },
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    isLoadMore: !0,
                    list: t.data.list.concat(e.data.data)
                }) : t.setData({
                    page: t.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(t) {
                console.log(t.msg);
            }
        }));
    },
    getLevels: function() {
        var t = this, e = a.getNetAddresss("plugin.fight-groups.frontend.store.team-store.get-levels");
        a._getNetWork({
            url: e,
            data: {
                id: this.data.id
            },
            success: function(a) {
                var e = a.data;
                1 == e.result && t.setData({
                    levels: e.data
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    changeEndTime: function(t) {
        this.setData({
            changeTimeID: t.currentTarget.dataset.id,
            currentDate: 1e3 * t.currentTarget.dataset.endtime,
            showDatetime: !0
        });
    },
    toDetail: function(t) {
        var a = t.currentTarget.dataset.id;
        a && wx.navigateTo({
            url: "/packageC/o2o/openGroupDetail/openGroupDetail?id=" + a
        });
    },
    confirmDate: function() {
        this.setData({
            showDatetime: !1
        });
        var t = this, e = a.getNetAddresss("plugin.fight-groups.frontend.store.team-store.change-end-time");
        a._getNetWork({
            url: e,
            data: {
                id: this.data.changeTimeID,
                end_time: this.data.currentDate / 1e3
            },
            success: function(a) {
                var e = a.data;
                wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                }), t.getData();
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    virtualTeam: function(t) {
        var e = this;
        wx.showModal({
            title: "提示",
            content: "是否虚拟成团",
            success: function(s) {
                if (s.confirm) {
                    var i = a.getNetAddresss("plugin.fight-groups.frontend.store.team-store.virtual-team");
                    a._getNetWork({
                        url: i,
                        data: {
                            team_id: t.currentTarget.dataset.id
                        },
                        success: function(t) {
                            var a = t.data;
                            wx.showToast({
                                title: a.msg,
                                icon: "none",
                                duration: 1e3
                            }), e.getData();
                        },
                        fail: function(t) {
                            console.log(t);
                        }
                    });
                } else s.cancel && console.log("用户点击取消");
            }
        });
    },
    onChange: function(t) {
        this.setData({
            leader_name: t.detail
        });
    },
    confirm: function() {
        this.getData(!0);
    },
    setMember_num: function(t) {
        var a = t.currentTarget.dataset.num;
        this.data.member_num != a ? (this.setData({
            member_num: a
        }), this.confirm()) : this.setData({
            member_num: ""
        });
    },
    onInput: function(t) {
        this.setData({
            currentDate: t.detail
        });
    },
    setStatus: function(t) {
        var a = t.currentTarget.dataset.id;
        this.data.status !== a ? (this.setData({
            status: a
        }), this.confirm()) : this.setData({
            status: ""
        });
    },
    onReady: function() {},
    onClickRight: function() {
        var t = !this.data.showFilter;
        this.setData({
            showFilter: t
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    clickShare: function(a) {
        var e;
        this.setData((e = {
            activeID: a.target.dataset.id,
            showShare: !0
        }, t(e, "activeInfo.title", a.target.dataset.title), t(e, "activeInfo.img", a.target.dataset.img), 
        e));
    },
    onClose: function() {
        this.setData({
            showShare: !1
        });
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function(t) {
        var a = wx.getStorageSync("yz_uid"), e = "";
        a && (e = a);
        var s = {
            title: "门店拼团开团列表",
            path: "/packageC/o2o/openGroupList/openGroupList?mid=" + e
        };
        return "button" == t.from && (s.title = this.data.activeInfo.title, s.imageUrl = this.data.activeInfo.img, 
        s.path = "/packageB/member/group/GroupDetail/GroupDetail?id=" + this.data.activeID + "&store_id=" + this.options.store_id + "&mid=" + e), 
        console.log("1111111111111", s), this.data.goodshare_info = {}, s;
    }
});